package com.tan00xu.utils;

import com.tan00xu.pojo.User;

public class UserThreadLocal {
    private UserThreadLocal() {}

    /**
     * 线程变量隔离
     * 线程变量，用于存储当前登录用户
     * 线程变量是在线程中共享的，可以认为是线程安全的
     */
    private static final ThreadLocal<User> USER_THREAD_LOCAL = new ThreadLocal<>();

    public static void set(User user) {
        USER_THREAD_LOCAL.set(user);
    }
    public static User get() {
        return USER_THREAD_LOCAL.get();
    }
    public static void remove() {
        USER_THREAD_LOCAL.remove();
    }


}
